/*
 * Author: vyouzhi <vyouzhi@163.com>
 * http://www.xda.cn
 *
 * File: record_lib.c
 * Create Date: 2011-07-13 11:27:54
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "record_lib.h"
#include "conf_lib.h"
#include "mysql_lib.h"
#include "time_lib.h"

void dorecord(const char *sub){
	int isrecord = 0;
	char *sql, *sqlescape, *logname, *isrec;
	char lgn[10];

	logname = get_logname();
	strcpy(lgn, logname);
	isrec = conf_get("isrecord");
	if(isrec)
		isrecord = atoi(isrec);
	
	if(isrecord){
		connect_sql();
		sqlescape = escape_mysql(sub);

		sql = (char *)calloc(strlen(sqlescape)+500, sizeof(char));

		sprintf(sql, "INSERT INTO `sql_log`.`sql_log_%s` (`sql`)VALUES ('%s');", lgn, sqlescape);	
		
		set_mysql(sql);

		free(sql);
		free(sqlescape);
	}
	free(logname);

}


/* vim: set ts=4 sw=4: */
